Skip to content

fix(pylock): reject unknown keys in 1.0 lock data - #1352

Open
r266-tech wants to merge 2 commits into
pypa:mainfrom
r266-tech:r266/pylock-reject-unknown-keys
Open

fix(pylock): reject unknown keys in 1.0 lock data#1352
r266-tech wants to merge 2 commits into
pypa:mainfrom
r266-tech:r266/pylock-reject-unknown-keys

Conversation

@r266-tech

@r266-tech r266-tech commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reject unknown keys in the closed objects of an exact pylock.toml 1.0 document before parsing can discard them
  • include the object path in validation errors for root, package, and nested source records
  • preserve open extension maps and the existing forward-compatible behavior for future 1.x versions

Rationale

Pylock.from_dict() currently ignores keys it does not consume. A typo such as
requires-pythn or markr therefore produces a valid-looking lock object after
silently removing an install-selection constraint.

The 1.0 schema closes the root, package, VCS, directory, archive, wheel, and
sdist objects. Dependency mappings, hashes, tool tables, and attestation
identity records remain open, so this change deliberately does not constrain
those extension-shaped mappings.

Testing

  • uv run pytest -q tests/test_pylock.py (72 passed)
  • full test suite with branch coverage (62403 passed, 1 skipped, 427 deselected; 100%)
  • Ruff check/format and git diff --check

@henryiii
henryiii requested a review from sbidoul July 27, 2026 18:25

@sbidoul sbidoul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The justification is about typos. But pylock files are meant to be generated by tools so that should not be an issue.

Ignoring unknown keys seems fine to me and I don't have much appetite to spend energy reviewing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants